﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TPLinkNetworking;

namespace HomeSuiteHome
{
    public partial class ModuleSettings : Form
    {
        private TPLinkConnection.SmartLink moduleSmartLink;
        public ModuleSettings(TPLinkConnection.SmartLink moduleLink)
        {
            InitializeComponent();
            moduleSmartLink = moduleLink;
        }

        private void ModuleSettings_Load(object sender, EventArgs e)
        {
            txt_moduleName.Text = moduleSmartLink.ModuleInformation.system.get_sysinfo.alias;
            switch (moduleSmartLink.ModuleInformation.system.get_sysinfo.led_off)
            {
                case 1:
                    rd_Status_Light_off.Checked = true;
                    break;
                default:
                    rd_Status_Light_On.Checked = true;
                    break;
            }
        }

        private void btn_save_Click(object sender, EventArgs e)
        {
            var connection = new TPLinkConnection();
            connection.UpdateModuleNameInformation(moduleSmartLink, txt_moduleName.Text);
            connection.UpdateModuleLedState(moduleSmartLink, rd_Status_Light_On.Checked);
            this.Close();

        }
    }
}
